//创建临时cookie
function setCookie(key, c_value) {
    document.cookie = key + "=" + c_value;
}

function setCookie(key, value, day) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + day);
    document.cookie = key + "=" + escape(value) + ((day == null) ? "" : ";expires=" + exdate.toGMTString());
}
//获取cookie
function getCookie(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
    if (arr = document.cookie.match(reg))
        return unescape(arr[2]);
    else
        return null;
}
function delCookie(name) {
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null)
        document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}